/*
This file replicates the tables and figures reported in:
Well-Behaved Women: Engendering Political Interest in Survey Research
Comparative Political Studies, TBD

(Last updated 21 September 2023)

Authors: Erum Haider (ehaider@wooster.edu), Irfan Nooruddin (in62@georgetown.edu)

This replication do-file references the following data-files:

1) WBW NES2009 Replication.dta

2) WBW NES2014 Replication.dta

3) WBW Original2019 Replication.dta

4) WBW afrobarometer2015.dta

Note that we use the 'lean2' graphing scheme. To install it: search lean2 

Lines 31-567 of this do-file pertain to the tables and figures in the main manuscript. 
Code required to reproduce the results reported in our supplementary materials begin
on line 579.

*/

cd  // Change working directory to wherever all the data-files are saved
set more off 

********************************************************************************
**MAIN TEXT
********************************************************************************

use "WBW NES2009 Replication.dta", clear


*DV1 - Political interest = polint
tab polint q8, missing

*DV2 - Political Opinion index = index09 

gen congressdk=0 if q20==8
replace congressdk=1 if q20!=8
gen partiesdk=0 if q21==8
replace partiesdk=1 if q21!=8
gen rungovtdk=0 if q22==8
replace rungovtdk=1 if q22!=8
gen cogovtdk=0 if q23==8
replace cogovtdk=1 if q23!=8
gen demdk=0 if q24==8
replace demdk=1 if q24!=8
gen stategovdk=0 if q25==8
replace stategovdk=1 if q25!=8

**The index runs from 0-6, with 6 being if you answer all the questions and 0 if you don't. This way, we compare individuals' likelihood of answering questions. A negative coefficient will indicate a person was less likely to answer the questions if observed 
gen index09= congressdk + partiesdk + rungovtdk + cogovtdk + demdk + stategovdk

*DV3 Current Affairs Opinion = opindex
gen povertydk=0 if q26a==8
replace povertydk=1 if q26a!=8
gen foreigndk=0 if q26b==8
replace foreigndk=1 if q26b!=8
gen armydk=0 if q26c==8
replace armydk=1 if q26c!=8
gen employeesdk=0 if q26d==8
replace employeesdk=1 if q26d!=8
gen factoriesdk=0 if  q26e==8
replace factoriesdk=1 if q26e!=8
gen strikedk=0 if q26f==8
replace strikedk=1 if q26f!=8
gen wardk=0 if q26g==8
replace wardk=1 if q26g!=8

gen opindex= povertydk + foreigndk+ armydk+ employeesdk+ factoriesdk+ strikedk+ wardk 

** Participate
gen part1 = (q5a==1) if q5a !=.
gen part2 = (q5b==1) if q5b !=.
gen part3 = (q6==1) if q6 !=.
gen participate= part1 + part2 + part3 

** Vote 
gen vote1=.
replace vote1=1 if q1==2
replace vote1=0 if q1==1


*Covariates

gen female = (z3==2)
replace female=. if z3==0 | z3==3
label define femlabel 1 "Women" 0 "Men", replace
label values female femlabel

gen urbanicity=z11 if z11!=.
gen village=(z11==1) if z11!=.
label define village 0 "Non-Rural" 1 "Rural", replace
label values village village

gen st = (z7a==2)
gen sc = (z7a==1)
gen obc = (z7a==3) if z7a!=.
gen hindu = (z8==1) if scaste1!=.
gen age3=z2 if z2>=18
gen married = (z4 == 1 | z4==2) if z4 !=9
tab z4 married , missing

** Father's education
gen fathered=1 if z5c_f==0 
replace fathered=2 if z5c_f==1 | z5c_f==2 | z5c_f==3
replace fathered=3 if z5c_f==4 | z5c_f==5 
replace fathered=4 if z5c_f==6 | z5c_f==7 | z5c_f==8
label define edu 1 "1: Non Literate" 2 "2: Below Matric fail" 3 "3: Matric and some college" 4 "4: College plus", replace
label values fathered edu

***Education 
gen educ=1 if z5==0 | z5==9
replace educ=2 if z5==1 | z5==2 | z5==3
replace educ=3 if z5==4 | z5==5 
replace educ=4 if z5==6 | z5==7 | z5==8
label define edu 1 "1: Non Literate" 2 "2: Below Matric fail" 3 "3: Matric and some college" 4 "4: College plus", replace
label values educ edu

*Income  
recode z18 (0 / 1000=1) (1001 / 2000=2) ///
 (2001 / 3000=3) (3001/4000=4)(4001 / 5000=5) ///
 (5001 / 10000=6) (10001 / 20000=7) ///
 (20001 / 550050=8) (nonmissing = .) (missing = .), gen(income)
 
* Literate/Non-Literate
gen literate = (educ!=1) if educ!=.
label define literate 0 "Non-Literate" 1 "Literate", replace
label values literate literate


**Treatment: Observers variable
gen observers=x2 if x2!=9 & x2!=0
label define obs2009 1 "No One" 2 "Children" 3 "Husband" 4 "Other Adults" 5 "Small Crowd", replace
label values observers obs2009


**ALL ADULT OBSERVERS. Men and women same
gen TREATFULL = (observers == 3 | observers ==4 |observers ==5) if observers !=.


*Matching procedure using psmatch2. 
************************************************************************************************
** IF YOU HAVE PSMATCH2 INSTALLED, THEN PROCEED. IF NOT, FIRST INSTALL USING COMMAND BELOW**
* net install psmatch2.pkg
************************************************************************************************

/*
To replicate the published findings, skip this and move to the code for Figure 1. Re-randomizing will lead 
to different n-n matching and therefore different estimated coefficients than in the published version. See the appendix 
for robustness checks. See "Appendix Tables and Figures" for Appendix graphs


*Randomize dataset -- This will lead to different coefficients for n-n matching
sort st_id pc_id ac_id ps_id res
set seed 12345
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'




psmatch2 TREATFULL female married educ fathered income urbanicity age sc st obc hindu, common 
pstest   female married educ fathered income urbanicity age sc st obc hindu, both
psgraph, bin(800)

*/



**Figure 1 - NES 2009: Bystanders present during the Indian and African National Surveys, by Gender
* This is the NES 2009 histogram that is in the upper-left-hand quadrant of Figure 1 in the paper

twoway (hist observers, horizontal discrete percent ysc(reverse) by(female) fcolor(edkblue)), ylabel(1(1)5, angle(0) valuelabel)  xlabel(0(10)50) ytitle("") note("N=34,153", span)

**Table 1 - NES 2009: Political opinions and interest for female respondents
	
logit polint i.observers married educ fathered income urbanicity age sc st obc hindu i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 
logit index09 i.observers married educ fathered income urbanicity age sc st obc hindu i.st_id [fweight= _weight] if female==1 & _support == 1 & _weight !=., robust 
logit opindex i.observers married educ fathered income urbanicity age sc st obc hindu i.st_id [fweight= _weight] if female==1 & _support == 1 & _weight !=., robust

** Table 3 - Participating in election campaigns for female respondents, NES 2009 
** This is column 1 of Table 3 in the paper

logit participate i.observers married educ fathered income urbanicity age sc st obc hindu  i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 
 
 
*** Figure 2 - NES 2009: Interaction between location and observer effects 

quietly reg polint i.observers##village i.st_id [fweight= _weight] if female==1 & _support == 1 & _weight!=., robust 
*outreg2 using VillageInt.tex, replace title(Table 1: Logit Results) ctitle(NES2009) alpha(0.01, 0.05, 0.1) symbol(***, **, *) se bdec(3)
*estimates store polint
qui: margins village, at(observers=(1(1)5))
 marginsplot,  scheme(lean2) name (polint, replace) title(Political Interest) xtitle("") xlabel(, labsize(small) alternate) plotopts(msize(small))  legend(label(1 "Non-Rural") label(2 "Rural")) legend(pos(6) row(1) size(small)) plot2opts(lpattern("--"))

quietly reg index09 i.observers##village  i.st_id [fweight= _weight] if female==1 & _support == 1 & _weight!=., robust 
*outreg2 using VillageInt.tex, append title(Table 1: Logit Results) ctitle(NES2009) alpha(0.01, 0.05, 0.1) symbol(***, **, *) se bdec(3)
*estimates store index09
qui: margins village, at(observers=(1(1)5))
 marginsplot,  scheme(lean2) name (polop, replace) title(Political Opinion Index) xtitle("") xlabel(, labsize(small) alternate) plotopts(msize(small))  legend(pos(6) row(1) size(small)) plot2opts(lpattern("--"))

quietly reg opindex i.observers##village  i.st_id [fweight= _weight] if female==1 & _support == 1 & _weight!=., robust 
*outreg2 using VillageInt.tex, append title(Table 1: Logit Results) ctitle(NES2009) alpha(0.01, 0.05, 0.1) symbol(***, **, *) se bdec(3)
*estimates store opindex
qui: margins village, at(observers=(1(1)5))
 marginsplot,  scheme(lean2) name (curraf, replace) title(Current Affairs Index) xtitle("") xlabel(, labsize(small) alternate) plotopts(msize(small))  legend(pos(6) row(1) size(small)) plot2opts(lpattern("--"))

  grc1leg polint polop curraf, rows(2) legendfrom(polint) scheme(lean2) 


*** Figure 3 - NES 2009: Interaction between education and observer effects

quietly reg polint i.observers##literate i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 
qui: margins literate, at(observers=(1(1)5))
 marginsplot,  scheme(lean2) name (polint, replace) legend(pos(6) row(1) size(small)) title(Political Interest) xtitle("") xlabel(, labsize(small) alternate) plotopts(msize(small))  plot2opts(lpattern("--"))

quietly reg index09 i.observers##literate  i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 
qui: margins literate, at(observers=(1(1)5))
 marginsplot,  scheme(lean2) name (polop, replace) legend(pos(6) row(1) size(small)) title(Political Opinion Index) xtitle("") xlabel(, labsize(small) alternate) plotopts(msize(small))  plot2opts(lpattern("--"))

quietly reg opindex i.observers##literate i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 
qui: margins literate, at(observers=(1(1)5))
 marginsplot,  scheme(lean2) name (curraf, replace) legend(pos(6) row(1) size(small)) title(Current Affairs Index) xtitle("") xlabel(, labsize(small) alternate) plotopts(msize(small))  plot2opts(lpattern("--"))
 
  grc1leg polint polop curraf, rows(2) legendfrom(polint) scheme(lean2) 

/*
To delete all the variables created in the code above, run the following commands to return to a base data set:

drop congressdk partiesdk rungovtdk cogovtdk demdk stategovdk index09 
drop opindex povertydk  foreigndk armydk employeesdk factoriesdk strikedk wardk
drop part1 part2 part3 participate 
drop vote1 female urbanicity village st sc hindu age3 obc married
drop edu fathered educ income literate
drop observers TREATFULL


*/  
  
  
************************ 
************************
******NES 2014*****
************************
************************


use "WBW NES2014 Replication.dta", clear


***DV1: Current Affairs = currentaf
gen majoritydk=0 if q10a==8
replace majoritydk=1 if q10a!=8 
gen minoritydk=0 if q10b==8
replace minoritydk=1 if q10b!=8 
gen reservdk=0 if q10c==8
replace reservdk=1 if q10c!=8 
gen terrordk=0 if q10d==8
replace terrordk=1 if q10d!=8 
gen indiadk=0 if q10e==8
replace indiadk=1 if q10e!=8 

gen currentaf= majoritydk + minoritydk + reservdk + terrordk + indiadk

*** DV2: General Opinion = genop14
gen dkq23a=0 if q23a==8
replace dkq23a=1 if q23a!=8
gen dkq23b=0 if q23b==8
replace dkq23b=1 if q23b!=8
gen dkq23c=0 if q23c==8
replace dkq23c=1 if q23c!=8
gen dkq23d=0 if q23d==8
replace dkq23d=1 if q23d!=8

gen genop14= dkq23a + dkq23b + dkq23c + dkq23d


***Party opinion = opindex
gen dkq15a=0 if q15a==98
replace dkq15a=1 if q15a!=98
gen dkq15b=0 if q15b==98
replace dkq15b=1 if q15b!=98
gen dkq15c=0 if q15c==98
replace dkq15c=1 if q15c!=98
gen dkq15d=0 if q15d==98
replace dkq15d=1 if q15d!=98
gen dkq15e=0 if q15e==98
replace dkq15e=1 if q15e!=98

gen opindex= dkq15a + dkq15b + dkq15c +dkq15d +dkq15e

*Participate
gen part1 = (q6a==2) if q6a !=.
gen part2 = (q6b==2) if q6b !=.
gen part3 = (q6c==2) if q6c !=.
gen part4 = (q6d==2) if q6d !=.
gen part5 = (q6e==2) if q6e !=.

gen participate= part1 + part2 + part3 +part4 + part5


**Covariates
gen female=(z2==2) if z2!=.
label define femlabel 1 "Women" 0 "Men", replace
label values female femlabel

tab loca1, m // 1: Village, 2: Town/city, 3: Metro
tab redu, m // 1: Non Literate, 2: Upto Primary, 3: Upto Matric, 4: College and above
tab fedu, m // 1: Non Literate, 2: Upto Primary, 3: Upto Matric, 4: College and above

*caste coding 
gen st = (scaste1 == 4) if scaste1 !=.
gen sc = (scaste1 == 3) if scaste1 !=.
gen obc = (scaste1 == 2) if scaste1 !=.
gen hindu=(z6==1) if z6!=.

tab age1, missing // Age categories for respondent for adults, coded by NES from z1
sum income // Income categories, coded by NES from z13


*** Treatment = Observers 
gen observers=1 if e1==1
replace observers=2 if e1==2 & female==1
replace observers=. if e1==2 & female==0
replace observers=3 if e1==3 | e1==4
replace observers=4 if e1==5 | e1==6
replace observers=5 if e1==7
replace observers=5 if e1==8

tab e1 observers, m

label define obs1 1 "No One" 2 "Husband" 3 "Other Adult Family" 4 "Neighbors" 5 "Small Crowd", replace
label values observers obs1

*Treatment, treat for male and female both. The regression models are restricted to female sample, so this doesn't impact the model. 

gen TREATFULL = (e1 ==2 | e1 == 3 | e1==4 | e1==5 | e1==6 | e1==7 | e1==8) if e1 !=.
tab e1 TREATFULL, missing

/*
To replicate the published findings, skip this and move to the code for Figure 1. Re-randomizing will lead 
to different n-n matching and therefore different estimated coefficients than in the published version. See the appendix 
for robustness checks.

*Randomize dataset -- This will lead to different coefficients for n-n matching

sort state_id pc_id ac_id ps_id resno
set seed 12345
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'

** Matching on TREATFULL: female here or not?

psmatch2 TREATFULL female redu fedu income loca1 age1 sc st obc hindu, common 
pstest female redu fedu income loca1 age1 sc st obc hindu, both
psgraph, bin(800)

*/

**Figure 1 - NES 2014: Bystanders present during the Indian and African National Surveys, by Gender
* This is the NES 2014 histogram that is in the upper-left-hand quadrant of Figure 1 in the paper

hist obs, horizontal discrete percent ysc(reverse) by(female) ylabel(1(1)5, valuelabel) fcolor(edkblue) xlabel(0(10)50)

*** Table 2 - NES 2014: 
**DV: Current Affairs
logit currentaf i.observers redu fedu income loca1 age1 sc st obc hindu i.state_id [fweight=_weight] if female==1 & _support==1 & _weight!=., robust 
**DV: General Opinion 
 logit genop14 i.observers redu fedu income loca1 age1 sc st obc hindu i.state_id [fweight=_weight] if female==1 & _support==1 & _weight!=., robust 

*** Table 3 - Participate
** This is column 2 of Table 3 in the paper

logit participate i.observers redu fedu income loca1 age1 sc st obc hindu i.state_id [fweight= _weight] if female==1 & _support == 1 & _weight !=., robust
  
/*
To delete all the variables created in the code above, run the following commands to return to a base data set:

drop majoritydk minoritydk reservdk terrordk indiadk currentaf dkq23a dkq23b dkq23c dkq23d genop14
drop dkq15a dkq15b dkq15c dkq15d dkq15e opindex part1 part2 part3 part4 part5 participate 
drop female st sc obc hindu observers TREATFULL

*/
  
  
************************ 
************************
******Original 2019*****
************************
************************


use "WBW Original2019 Replication.dta", clear


** DV1: Political Interest 
gen polint=.
replace polint=1 if Q7==1 | Q7==2
replace polint=0 if Q7==3 | Q7==4 | Q7==7 | Q7==8

tab Q7 polint, m

** DV2: Political Opinion Index (13 points)
gen Q13adk= (Q13a!=3) 
gen Q13bdk= (Q13b!=3) 
gen Q13cdk= (Q13c!=3) 
gen Q13ddk= (Q13d!=3) 
gen Q13edk= (Q13e!=3) 
gen Q13fdk= (Q13f!=3) 
gen Q13gdk= (Q13g!=3) 
gen Q13hdk= (Q13h!=3) 
gen Q13idk= (Q13i!=3) 
gen Q13jdk= (Q13j!=3)
gen Q13kdk= (Q13k!=3) 
gen Q13ldk= (Q13l!=3) 
gen Q13mdk= (Q13m!=3) 

gen index = Q13adk + Q13bdk + Q13cdk + Q13ddk + Q13edk + Q13fdk + Q13gdk + Q13hdk +Q13idk + Q13jdk + Q13kdk + Q13ldk+ Q13mdk

**Participate
gen part1 = (Q4_1==2) if Q4_1 !=.
gen part2 = (Q4_2==2) if Q4_2 !=.
gen part3 = (Q4_3==2) if Q4_3 !=.
gen part4 = (Q4_4==2) if Q4_4 !=.
gen part5 = (Q4_5==2) if Q4_5 !=.

gen participate= part1 + part2 + part3 +part4 + part5

** Vote
gen vote=(Q1==1) if Q1!=.

** Covariates
gen female=1 if B2==2
replace female=0 if B2!=2
label define femlabel 1 "Women" 0 "Men", replace
label values female femlabel

gen sc=(B10a==1) if B10a!=.
gen st=(B10a==2) if B10a!=.
gen obc= (B10a==3) if B10a!=.
gen hindu=(B9==1) if B9!=.
gen age=B1
gen married = (B4 == 1 | B4==2) if B4 !=8

** Location
gen loca1=.
replace loca1=1 if B6==1
replace loca1=2 if B6==2 | B6==3
replace loca1=3 if B6==4

* Respondent Education
gen redu=B3

**Literate/Non-Literate
gen literate = (redu>=3) if redu<97

label define lit 1 "Literate" 0 "Non-Literate", replace
label value literate lit


** Income
recode B8 (0 / 1000=1) (1001 / 2000=2) ///
 (2001 / 3000=3) (3001/4000=4)(4001 / 5000=5) ///
 (5001 / 10000=6) (10001 / 20000=7) ///
 (20001 / 550050=8) (nonmissing = .) (missing = .), gen(income)

**Treatment: All adult observers

gen observers=.  if E1==8
replace observers=1 if E1==1 
replace observers=2 if E1==2 & female==1
replace observers=3 if E1==3 | E1==4 
replace observers=. if E1==2 & female==0
replace observers=4 if E1==5 | E1==6
replace observers=5 if E1==7

label define obs1 1 "No One" 2 "Husband" 3 "Other Adult Family" 4 "Neighbors" 5 "Small Crowd", replace
label values observers obs1

gen TREATFULL = (E1 == 2 | E1 == 3 | E1 == 4 | E1 == 5 | E1 == 6 | E1 == 7) if E1!=8
tab E1 TREATFULL, m


 /*
To replicate the published findings, skip this and move to the code for Figure 1. Re-randomizing will lead 
to different n-n matching and therefore different estimated coefficients than in the published version. See the appendix 
for robustness checks.

*Randomize dataset -- This will lead to different coefficients for n-n matching

browse
sort sys_tot
set seed 12345
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'

** Matching on Treatment
  psmatch2 TREATFULL female married  redu income loca1 age sc st obc hindu, common 
 pstest female married  redu income loca1 age sc st obc hindu, both
psgraph, bin(800)

*/

*** Figure 1 - Original 2019: Bystanders present during the Indian and African National Surveys, by Gender
* This is the Original 2019 histogram that is in the lower-right-hand quadrant of Figure 1 in the paper

hist obs, horizontal discrete percent ysc(reverse) by(female) ylabel(1(1)5, valuelabel angle(0)) fcolor(edkblue) xlabel(0(10)60) ytitle("")


***Table 2: Original 2019, Political Opinions and interest for female respondents
** Columns 3 and 4 of Table 2 in the paper

logit polint i.observers married redu income loca1 age sc st obc hindu i.State_id [fweight= _weight] if female==1 & _support == 1 & _weight !=., robust
*outreg2 using Table2Orig2019.tex, replace title(Orig2019Table2) ctitle(CSESIndex) alpha(0.01, 0.05, 0.1) symbol(***, **, *) se bdec(3)

logit index i.observers married redu income loca1 age sc st obc hindu i.State_id [fweight= _weight] if female==1 & _support == 1 & _weight !=. , robust 
*outreg2 using Table2Orig2019.tex, append title(Orig2019Table2) ctitle(CSESIndex) alpha(0.01, 0.05, 0.1) symbol(***, **, *) se bdec(3)


** Table 3: Participating in election campaigns for female respondents
** Column 3 of Table 3 in the papers

logit participate i.observers married redu income loca1 age sc st obc hindu i.State_id [fweight= _weight] if female==1 & _support == 1 & _weight !=. , robust 
*outreg2 using Table3Orig2019.tex, replace title(Orig2019Table2) ctitle(CSESIndex) alpha(0.01, 0.05, 0.1) symbol(***, **, *) se bdec(3)

*Figure 4: Original 2019 interaction between education and observer effects 

quietly reg polint i.observers##i.literate  i.State_id [fweight= _weight] if female==1 & _support == 1 & _weight !=., robust
qui: margins literate, at(observers=(1(1)5))
 marginsplot,  scheme(lean2) name (polint, replace) title(Political Interest) xtitle("") plotopts(msize(small))  legend(pos(6) rows(1)) plot2opts(lpattern("--")) 
 
quietly reg index i.observers##i.literate  i.State_id [fweight= _weight] if female==1 & _support == 1 & _weight !=. , robust 
qui: margins literate, at(observers=(1(1)5))
 marginsplot,  scheme(lean2) name (index, replace) title(Political Opinion Index) xtitle("") plotopts(msize(small))   legend(rows(1)) plot2opts(lpattern("--"))

 grc1leg polint index, rows(2) legendfrom(polint) scheme(lean2) 
 
 /*
To delete all the variables created in the code above, run the following commands to return to a base data set:

drop polint 
drop index Q13adk Q13bdk Q13cdk Q13ddk Q13edk Q13fdk Q13gdk Q13hdk Q13idk Q13jdk Q13kdk Q13ldk Q13mdk
drop part1-part5 participate vote 
drop female sc st age hindu married obc loca1 redu literate income
drop observers TREATFULL

*/

*************************
*** Afrobarometer 2015***
*************************

use "WBW afrobarometer2015.dta", clear
 
*** Figure 1 - Afrobarometer 2015: Bystanders present during the Indian and African National Surveys, by Gender
** This is the Afrobarometer 2015 figure in the lower-left quadrant of Figure 1 in the paper

label define femlabel 1 "Women" 0 "Men", replace
label values female femlabel



***********************************************************************************************************************************************************
***********************************************************************************************************************************************************

*** SUPPLEMENTARY TABLES ***

***********************************************************************************************************************************************************
***********************************************************************************************************************************************************

** A2.1 - NES 2009 Summary Statistics
ttest TREATFULL, by(female)
ttest married, by(female)
ttest educ, by(female)
ttest fathered, by(female)
ttest income, by(female)
ttest urbanicity, by(female)
ttest z2 if z2>18, by(female)
ttest sc, by(female)
ttest st, by(female)
ttest obc, by(female)
ttest hindu, by(female)


** A3.1 - NES 2009 Propensity score matching 

qui: twoway (kdensity _pscore if TREATFULL==1) (kdensity _pscore if TREATFULL==0, /// 
    lpattern(dash)), legend( label (1 "Observed during interview")  label (2 "Alone during interview") rows(1)) ///
	xtitle("Propensity score") name(unmatched, replace) title("Raw data: unmatched") ///
	ytitle("Density") ylabel(none) scheme(s1mono) 
	
	qui: twoway (kdensity _pscore if TREATFULL==1) (kdensity _pscore if TREATFULL==0 ///
	[aweight=_w], lpattern(dash)), legend( label (1 "Observed during interview") label (2 "Alone during interview") rows(1)) ///
	xtitle("Propensity score") ytitle("Density") name(mahalanobis, replace) title("Matched: Mahalanobis") scheme(s1mono) ylabel(none) 
		
qui: twoway (kdensity _pscore if TREATFULL==1) (kdensity _pscore if TREATFULL==0 ///
	[aweight=kernel_epan] , lpattern(dash)), legend( label (1 "Observed during interview") label (2 "Alone during interview") rows(1)) ///
	xtitle("Propensity score") ytitle("Density") name(kernel, replace) title("Matched: Kernel") ///
	 ylabel(none) scheme(s1mono)  
	
	grc1leg unmatched kernel mahalanobis, rows(2) name(PSM1, replace) /// 
		scheme(s1mono) legendfrom(kernel) title("Propensity Score Matching") 

** A5.1: Privacy - The likelihood of being observed during surveys, NES 2009

reg TREATFULL female married educ fathered income urbanicity age sc st obc hindu i.st_id, robust

** A6.1: Who's watching? Observers during surveys of female re-spondents, NES 2009

reg female i.observers married educ fathered income urbanicity age sc st obc hindu i.st_id, robust

** A7.1: Propensity score matching results for NES 2009, Treatment: Adult observers

pstest female married educ fathered income urbanicity age sc st obc hindu, both

** A10.1: Voting among female respondents - observer effects, NES 2009 

 logit vote1 i.observers married educ fathered income urbanicity age sc st obc hindu i.st_id [fweight= _weight] if female==1 & _support == 1 & _weight !=., robust

** A11.1: NES 2009: Political opinions and interest for male respondents

logit polint i.observers married educ fathered income urbanicity age sc st obc hindu i.st_id [fweight= _weight]if female==0 & _support == 1 & _weight!=., robust 
logit index09 i.observers married educ fathered income urbanicity age sc st obc hindu i.st_id [fweight= _weight] if female==0 & _support == 1 & _weight !=., robust 
logit opindex i.observers married educ fathered income urbanicity age sc st obc hindu i.st_id [fweight= _weight] if female==0 & _support == 1 & _weight !=., robust

** A14.1: Participation in election campaigns for male respondents, NES 2009
logit participate i.observers married educ fathered income urbanicity age sc st obc hindu i.st_id [fweight= _weight] if female==0 & _support == 1 & _weight!=., robust 

** A15.1: Village Interaction Effects for Women: Reported Interest & Opinions, NES 2009, OLS

reg polint i.observers##village married educ fathered income age sc st obc hindu i.st_id [fweight= _weight] if female==1 & _support == 1 & _weight!=., robust 

reg index09 i.observers##village married educ fathered income age sc st obc hindu  i.st_id [fweight= _weight] if female==1 & _support == 1 & _weight!=., robust 

reg opindex i.observers##village married educ fathered income age sc st obc hindu i.st_id [fweight= _weight] if female==1 & _support == 1 & _weight!=., robust 

** A16.1: Literacy Interaction Effects for Women: Reported Interest & Opinions, NES 2009, OLS

reg polint i.observers##literate married fathered income urbanicity age sc st obc hindu i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 

reg index09 i.observers##literate married fathered income urbanicity age sc st obc hindu i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 

reg opindex i.observers##literate married fathered income urbanicity age sc st obc hindu i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 

** A18.1: Re-ordered and Matched, 200 Iterations, NES 2009
** See "Robustness Check" at end of this document


** A23.1: Matched and Unmatched Results for NES 2009, OLS
*Political Interest
	*Unmatched
reg polint i.observers##female married educ fathered income urbanicity age sc st obc hindu i.st_id, robust
	*Matched
reg polint i.observers##female i.st_id [fweight= _weight] if  _support == 1 & _weight!=., robust 

*Political Opinion Index
	*Unmatched
reg index09 i.observers##female married educ fathered income urbanicity age sc st obc hindu i.st_id, robust
	*Matched
reg index09 i.observers##female i.st_id [fweight= _weight] if  _support == 1 & _weight!=., robust 

*Current Affairs Index
	*Unmatched
reg opindex i.observers##female married educ fathered income urbanicity age sc st obc hindu i.st_id, robust
	*Matched
reg opindex i.observers##female i.st_id [fweight= _weight] if _support == 1 & _weight !=., robust


** A26.1: NES 2009 Coefficients, Matched OLS
* Political Interest
quietly reg polint i.observers##i.female i.st_id [fweight= _weight] if _support == 1 & _weight!=., robust 
estimates store polint
*DV: Political Opinion Index (0-6)
quietly reg index09 i.observers##i.female  i.st_id [fweight= _weight] if  _support == 1 & _weight !=., robust 
estimates store index09
*DV: Current Affairs Index (0-7)
quietly reg opindex i.observers##i.female   i.st_id [fweight= _weight] if _support == 1 & _weight !=., robust
estimates store opindex

 
coefplot (polint, label(Political Interest) ) ///
(index09, label(Political Opinion Index)  ) ///
(opindex, label(Current Affairs Index)  ) ///
 , keep(*.observers#*.female) xline(0) levels(95 90) scheme(lean2) msize(small) xsc(r(-0.4 (0.1) 0.4)) title("NES 2009", size(medium)) ylabel(,labsize(small)) legend(pos(6) row(1) size(small))



*** A27.1: Marginsplot, Observer Effects interacted with Gender. NES 2009, Matched OLS
*Political Interest
quietly reg polint i.observers##female i.st_id [fweight= _weight] if _support == 1 & _weight!=., robust 
estimates store polint

qui: margins female, at(observers=(1(1)5))
marginsplot,  scheme(lean2) name (polint, replace) title(Political Interest) xtitle("") plotopts(msize(small))  legend(pos(6) row(1) size(small)) xlabel(, labsize(small)) plot2opts(lpattern("--"))

*DV: Political Opinion Index (0-6)
quietly reg index09 i.observers##female  i.st_id [fweight= _weight] if  _support == 1 & _weight !=., robust 
estimates store index09

qui: margins female, at(observers=(1(1)5))
marginsplot,  scheme(lean2) name (index09, replace) title(Political Opinion Index) xtitle("") plotopts(msize(small)) legend(pos(6) row(1) size(small)) plot2opts(lpattern("--"))

*DV: Current Affairs Index (0-7)
quietly reg opindex i.observers##female   i.st_id [fweight= _weight] if _support == 1 & _weight !=., robust
estimates store opindex

qui: margins female, at(observers=(1(1)5))
marginsplot,  scheme(lean2) name (opindex, replace) title(Current Affairs Index) xtitle("") plotopts(msize(small)) legend(pos(6) row(1) size(small)) plot2opts(lpattern("--"))

grc1leg index09 opindex, rows(3) legendfrom(index09) scheme(lean2) 


*** 28.1: Marginsplot, NES 2009, Observer Effects Interacted with Village/Rural Dummy Variable. Female-only subsample. Matched OLS.

quietly reg polint i.observers##village married educ fathered income age sc st obc hindu i.st_id [fweight= _weight] if female==1 & _support == 1 & _weight!=., robust 
qui: margins village, at(observers=(1(1)5))
marginsplot,  scheme(lean2) name (polint, replace) title(Political Interest) xtitle("") xlabel(, labsize(small) alternate) plotopts(msize(small))  legend(pos(6) row(1) size(small)) plot2opts(lpattern("--"))

quietly reg index09 i.observers##village married educ fathered income age sc st obc hindu  i.st_id [fweight= _weight] if female==1 & _support == 1 & _weight!=., robust 
qui: margins village, at(observers=(1(1)5))
marginsplot,  scheme(lean2) name (polop, replace) title(Political Opinion Index) xtitle("") xlabel(, labsize(small) alternate) plotopts(msize(small))  legend(pos(6) row(1) size(small)) plot2opts(lpattern("--"))

quietly reg opindex i.observers##village married educ fathered income age sc st obc hindu i.st_id [fweight= _weight] if female==1 & _support == 1 & _weight!=., robust 
qui: margins village, at(observers=(1(1)5))
marginsplot,  scheme(lean2) name (curraf, replace) title(Current Affairs Index) xtitle("") xlabel(, labsize(small) alternate) plotopts(msize(small))  legend(pos(6) row(1) size(small)) plot2opts(lpattern("--"))

grc1leg polint polop curraf, rows(2) legendfrom(polint) scheme(lean2) 


*** A29.1: Marginsplot, NES 2009, Observer Effects Interacted with Literate/Non-Literate Dummy Variable. Female-only subsample. Matched OLS.


reg polint i.observers##literate married fathered income urbanicity age sc st obc hindu i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 
qui: margins literate, at(observers=(1(1)5))
marginsplot,  scheme(lean2) name (polint, replace) legend(pos(6) row(1) size(small)) title(Political Interest) xtitle("") xlabel(, labsize(small) alternate) plotopts(msize(small))  plot2opts(lpattern("--"))

quietly reg index09 i.observers##literate married fathered income urbanicity age sc st obc hindu i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 

qui: margins literate, at(observers=(1(1)5))
marginsplot,  scheme(lean2) name (polop, replace) legend(pos(6) row(1) size(small)) title(Political Opinion Index) xtitle("") xlabel(, labsize(small) alternate) plotopts(msize(small))  plot2opts(lpattern("--"))

quietly reg opindex i.observers##literate married fathered income urbanicity age sc st obc hindu i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 
qui: margins literate, at(observers=(1(1)5))
marginsplot,  scheme(lean2) name (curraf, replace) legend(pos(6) row(1) size(small)) title(Current Affairs Index) xtitle("") xlabel(, labsize(small) alternate) plotopts(msize(small))  plot2opts(lpattern("--"))
 
grc1leg polint polop curraf, rows(2) legendfrom(polint) scheme(lean2) 


***A30.1: Marginsplot, Observer Effects interacted with Gender. Reported Voting across three surveys. Matched OLS, NES 2009
** This is the top graph of Figure A30.1

reg vote1 i.observers##female married educ fathered income urbanicity age sc st obc hindu i.st_id [fweight= _weight] if  _support == 1 & _weight !=., robust
qui: margins female, at(observers=(1(1)5))
marginsplot,  scheme(lean2) name (curraf, replace) legend(pos(6) row(1) size(small)) title(NES 2009) xtitle("") xlabel(, labsize(small) alternate) plotopts(msize(small))  plot2opts(lpattern("--"))


*** NES 2014
use "WBW NES2014 Replication.dta", clear


*** A2.1 - NES 2014: Summary statistics

ttest TREATFULL, by(female)
ttest redu, by(female)
ttest fedu, by(female)
ttest income, by(female)
ttest loca1, by(female)
ttest z1 if z1<98, by(female) 
ttest sc, by(female)
ttest st, by(female)
ttest obc, by(female)
ttest hindu, by(female)


*** A3.2: Propensity score matching for NES 2014 sample

	qui: twoway (kdensity _pscore if TREATFULL==1) (kdensity _pscore if TREATFULL==0 ///
	[aweight=_w], lpattern(dash)), legend( label (1 "Observed during interview") label (2 "Alone") rows(1)) ///
	xtitle("Propensity score") ytitle("Density") title("Matched: Mahalanobis") scheme(s1mono) ylabel(none) 

	
*** A5.1: Privacy - The likelihood of being observed during surveys, NES 2014
** This is column 2 "NES 2014" of Table A5.1

reg TREATFULL female redu fedu income loca1 age1 sc st obc hindu i.state_id if e1!=8, robust 


*** A6.1: Who's watching? Observers during surveys of female respondents, NES 2014

reg female i.e1 redu fedu income loca1 age1 sc st obc hindu i.state_id if e1!=8, robust 


*** A8.1: Propensity score matching results for NES 2014, Treatment: Adult observers

pstest female redu fedu income loca1 age1 sc st obc hindu, both


*** A10.1 Voting among female respondents - observer effects, NES 2014 
logit vote i.observers redu fedu income loca1 age1 sc st obc hindu i.state_id [fweight= _weight] if female==1 & _support == 1 & _weight !=., robust


*** A12.1 NES 2014: Political opinions and interest for male respondents
**  This is column 1 of Table 12.1
logit currentaf i.observers redu fedu income loca1 age1 sc st obc hindu i.state_id [fweight=_weight] if female==0 & _support==1 & _weight!=., robust
**  This is column 2 of Table 12.1
logit genop14 i.observers redu fedu income loca1 age1 sc st obc hindu i.state_id [fweight= _weight] if female==0 & _support == 1 & _weight !=., robust


*** A13.1: NES 2014 - Party performance index for men and women
**  This is column 1 of Table 13.1
logit opindex i.observers redu fedu income loca1 age1 sc st obc hindu i.state_id [fweight= _weight] if female==1 & _support == 1 & _weight !=., robust
**  This is column 2 of Table 13.1
logit opindex i.observers redu fedu income loca1 age1 sc st obc hindu i.state_id [fweight= _weight] if female==0 & _support == 1 & _weight !=., robust


*** A14.1: Participation in election campaigns for male respondents, NES 2014
**  This is column 2 of Table 14.1
logit participate i.observers redu fedu income loca1 age1 sc st obc hindu i.state_id [fweight= _weight] if female==0 & _support == 1 & _weight !=., robust


** A24.1: Matched and Unmatched Results for NES 2014, OLS

**DV: Current Affairs
	**Unmatched
reg currentaf i.observers##female redu fedu income loca1 age1 sc st obc hindu i.state_id, robust
	**Matched
reg currentaf i.observers##female i.state_id [fweight=_weight] if _support==1 & _weight!=., robust 

**DV: General Opinion 
	**Unmatched
reg genop14 i.observers##female redu fedu income loca1 age1 sc st obc hindu i.state_id, robust 
	**Matched
reg genop14 i.observers##female i.state_id [fweight=_weight] if _support==1 & _weight!=., robust 


*** A30.1: Marginsplot, Observer Effects interacted with Gender. Reported Voting across three surveys. Matched OLS, NES 2014
**  This is the second (middle) graph in Figure A30.1

quietly reg vote i.observers##female redu fedu income loca1 age1 sc st obc hindu i.state_id [fweight= _weight] if _support == 1 & _weight !=., robust
qui: margins female, at(observers=(1(1)5))
marginsplot,  scheme(lean2) name (curraf, replace) legend(pos(6) row(1) size(small)) title(NES 2014) xtitle("") xlabel(, labsize(small) alternate) plotopts(msize(small))  plot2opts(lpattern("--"))


**** Original 2019
use "WBW Original2019 Replication.dta", clear


*** A2.1 - Original 2019 Summary Statistics
ttest TREATFULL, by(female)
ttest married, by(female)
ttest redu, by(female)
ttest income, by(female)
ttest loca1, by(female)
ttest B1, by(female)
ttest sc, by(female)
ttest st, by(female)
ttest obc, by(female)
ttest hindu, by(female)


*** A3.3: Original 2019: Propensity Score Matching 

twoway (kdensity _pscore if TREATFULL==1) (kdensity _pscore if TREATFULL==0 ///
[aweight=_w], lpattern(dash)), legend( label (1 "Observed during interview") label (2 "Alone") rows(1)) ///
xtitle("Propensity score") ytitle("Density") title("Matched: Mahalanobis") scheme(s1mono) ylabel(none) 


*** A5.1: Privacy - The likelihood of being observed during surveys, Original 2019
**  This is column 3 of Table A5.1

reg  TREATFULL female married redu income loca1 age sc st obc hindu i.State_id if E1!=8, robust 


*** A6.1: Who's Watching? Observers during surveys of female respondents, Original 2019

reg female i.E1 married redu income loca1 age sc st obc hindu i.State_id if E1!=8, robust 


*** A9.1: Propensity score matching results for Original Survey 2019, Treatment: Adult observers

pstest female married redu income loca1 age sc st obc hindu, both


*** A10.1: Voting among female respondents - observer effects, Original 2019 

logit vote i.observers married redu income loca1 age sc st obc hindu i.State_id [fweight= _weight] if female==1 & _support == 1 & _weight !=. , robust 


*** A12.1: Original 2019: Political opinions and interest for male respondents
**  This is column 3 of Table A12.1
logit polint i.observers married redu income loca1 age sc st obc hindu i.State_id [fweight= _weight] if female==0 & _support == 1 & _weight !=., robust
**  This is column 4 of Table A12.1
logit index i.observers married redu income loca1 age sc st obc hindu i.State_id [fweight= _weight] if female==0 & _support == 1 & _weight !=. , robust 


*** A14.1: Participation in election campaigns for male respondents, Original 2019
**  This is column 3 of Table A14.1

logit participate i.observers married redu income loca1 age sc st obc hindu i.State_id [fweight= _weight] if female==0 & _support == 1 & _weight !=. , robust 


*** A17.1: Literacy Interaction Effects for Women: Reported Interest & Opinions, Original 2019
**  This is column 1 of Table A17.1
reg polint i.observers##literate married income loca1 age sc st obc hindu i.State_id [fweight= _weight] if female==1 & _support == 1 & _weight !=., robust
**  This is column 2 of Table A17.1
reg index i.observers##literate married income loca1 age sc st obc hindu i.State_id [fweight= _weight] if female==1 & _support == 1 & _weight !=., robust


*** A25.1: Matched and Unmatched Results for Original 2019, OLS
**DV: Political Interest 
	** Unmatched
reg polint i.observers##female married redu income loca1 age sc st obc hindu i.State_id, robust
	** Matched
reg polint i.observers##female i.State_id [fweight= _weight] if _support == 1 & _weight !=., robust	
** DV: Political Opinion Index
	** Unmatched
reg index i.observers##female married redu income loca1 age sc st obc hindu i.State_id, robust 
	**Matched
reg polint i.observers##female i.State_id [fweight= _weight] if _support == 1 & _weight !=., robust	


*** A30.1: Marginsplot, Observer Effects interacted with Gender. Reported Voting across three surveys. Matched OLS.

quietly reg vote i.observers##female married redu income loca1 age sc st obc hindu i.State_id [fweight= _weight] if _support == 1 & _weight !=., robust	
qui: margins female, at(observers=(1(1)5))
marginsplot,  scheme(lean2) name (curraf, replace) legend(pos(6) row(1) size(small)) title(Original 2019) xtitle("") xlabel(, labsize(small) alternate) plotopts(msize(small))  plot2opts(lpattern("--"))


**** Afrobarometer 2015
** A4.1 - Afrobarometer 2015: Likelihood of being observed during surveys

use "WBW afrobarometer2015.dta", clear

tab Q106, nolab

gen obs1=.  if Q106==-1
replace obs1=1 if Q106==1
replace obs1=2 if Q106==3
replace obs1=3 if Q106==2 
replace obs1=4 if Q106==4
replace obs1=5 if Q106==5

tab obs1 obs, missing

label define obs2 1 "No One" 2 "Children" 3 "Spouse" 4 "A few others" 5 "Small Crowd", replace
label values obs1 obs2

*** Treatment = all adult observers
gen treatfull = (obs != 1) if obs !=.

*Housing
gen housing=. if Q104==-1 | Q104==8
replace housing=1 if Q104==2 | Q104==3
replace housing=2 if Q104==1 | Q104==4 |Q104==5| Q104==6

reg treatfull female EDUC_COND housing urban i.country if EDUC_COND!=9, robust 


*** A18.1: Re-ordered and Matched, 200 Iterations, NES 2009
/* Note that the code below will not perfectly reproduce the results reported in Table 
A18.1 in the appendix given the nature of bootstrapping. But the results should 
approximate what we've reported */


** Political Interest, Alone, female sample

use "WBW NES2009 Replication.dta", clear

gen alone = (x2==1) if x2!=.
gen family = (x2==3 | x2==4) if x2!=.

	
* inverse probability weighting
gen ipw = .
replace ipw = 1 if TREATFULL == 1
replace ipw = _pscore/(1-_pscore) if TREATFULL == 0
	
* regression to estimate the treatment effect
 
logit polint alone i.st_id [pweight = ipw]if female==1 & _support == 1 & _weight!=., robust 


gen sample = e(sample)

* bootstrapping the IPW (200 times)
matrix boot = J(200,1,.)
forval j = 1/200 {
	preserve
	bsample if sample == 1
	quietly psmatch2 TREATFULL female married educ fathered income urbanicity age sc st obc hindu, common 
	replace ipw = .
	replace ipw = 1 if TREATFULL == 1
	replace ipw = _pscore/(1-_pscore) if TREATFULL == 0
	quietly logit polint alone i.st_id [pweight = ipw] if female==1 & _support == 1 & _weight!=., robust 
	matrix boot[`j',1] = _b[alone]
	restore
	}

clear
svmat boot
sum

** Political Interest, Alone, male sample
use "WBW NES2009 Replication.dta", clear

gen alone = (x2==1) if x2!=.
gen family = (x2==3 | x2==4) if x2!=.

	
* inverse probability weighting
gen ipw = .
replace ipw = 1 if TREATFULL == 1
replace ipw = _pscore/(1-_pscore) if TREATFULL == 0
	
* regression to estimate the treatment effect
 
logit polint alone i.st_id [pweight = ipw]if female==0 & _support == 1 & _weight!=., robust 


gen sample = e(sample)

* bootstrapping the IPW (200 times)
matrix boot = J(200,1,.)
forval j = 1/200 {
	preserve
	bsample if sample == 1
	quietly psmatch2 TREATFULL female married educ fathered income urbanicity age sc st obc hindu, common 
	replace ipw = .
	replace ipw = 1 if TREATFULL == 1
	replace ipw = _pscore/(1-_pscore) if TREATFULL == 0
	quietly logit polint alone i.st_id [pweight = ipw] if female==0 & _support == 1 & _weight!=., robust 
	matrix boot[`j',1] = _b[alone]
	restore
	}

clear
svmat boot
sum

*** Political Opinion Index, Family, female sample
use "WBW NES2009 Replication.dta", clear

gen alone = (x2==1) if x2!=.
gen family = (x2==3 | x2==4) if x2!=.

	
* inverse probability weighting
gen ipw = .
replace ipw = 1 if TREATFULL == 1
replace ipw = _pscore/(1-_pscore) if TREATFULL == 0
	
* regression to estimate the treatment effect
 
logit index09 alone i.st_id [pweight = ipw]if female==1 & _support == 1 & _weight!=., robust 


gen sample = e(sample)

* bootstrapping the IPW (200 times)
matrix boot = J(200,1,.)
forval j = 1/200 {
	preserve
	bsample if sample == 1
	quietly psmatch2 TREATFULL female married educ fathered income urbanicity age sc st obc hindu, common 
	replace ipw = .
	replace ipw = 1 if TREATFULL == 1
	replace ipw = _pscore/(1-_pscore) if TREATFULL == 0
	quietly logit index09 family i.st_id [pweight = ipw] if female==1 & _support == 1 & _weight!=., robust 
	matrix boot[`j',1] = _b[family]
	restore
	}

clear
svmat boot
sum

*** Current Affairs Index, Family, Female sample
use "WBW NES2009 Replication.dta", clear

gen alone = (x2==1) if x2!=.
gen family = (x2==3 | x2==4) if x2!=.

	
* inverse probability weighting
gen ipw = .
replace ipw = 1 if TREATFULL == 1
replace ipw = _pscore/(1-_pscore) if TREATFULL == 0
	
* regression to estimate the treatment effect
 
logit opindex family i.st_id [pweight = ipw]if female==1 & _support == 1 & _weight!=., robust 


gen sample = e(sample)

* bootstrapping the IPW (200 times)
matrix boot = J(200,1,.)
forval j = 1/200 {
	preserve
	bsample if sample == 1
	quietly psmatch2 TREATFULL female married educ fathered income urbanicity age sc st obc hindu, common 
	replace ipw = .
	replace ipw = 1 if TREATFULL == 1
	replace ipw = _pscore/(1-_pscore) if TREATFULL == 0
	quietly logit opindex family i.st_id [pweight = ipw] if female==1 & _support == 1 & _weight!=., robust 
	matrix boot[`j',1] = _b[family]
	restore
	}

clear
svmat boot
sum

*** Voting, Alone, female sample
use "WBW NES2009 Replication.dta", clear

gen alone = (x2==1) if x2!=.
gen family = (x2==3 | x2==4) if x2!=.

	
* inverse probability weighting
gen ipw = .
replace ipw = 1 if TREATFULL == 1
replace ipw = _pscore/(1-_pscore) if TREATFULL == 0
	
* regression to estimate the treatment effect
 
logit vote1 alone i.st_id [pweight = ipw]if female==1 & _support == 1 & _weight!=., robust 


gen sample = e(sample)

* bootstrapping the IPW (200 times)
matrix boot = J(200,1,.)
forval j = 1/200 {
	preserve
	bsample if sample == 1
	quietly psmatch2 TREATFULL female married educ fathered income urbanicity age sc st obc hindu, common 
	replace ipw = .
	replace ipw = 1 if TREATFULL == 1
	replace ipw = _pscore/(1-_pscore) if TREATFULL == 0
	quietly logit vote1 alone i.st_id [pweight = ipw] if female==1 & _support == 1 & _weight!=., robust 
	matrix boot[`j',1] = _b[alone]
	restore
	}

clear
svmat boot
sum


** A19.1: Robustness Check for Political Interest, 200 Iterations, NES 2009

use "WBW NES2009 Replication.dta", clear

sort st_id pc_id ac_id ps_id res
set seed 12345
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'

psmatch2 TREATFULL female married educ fathered income urbanicity age sc st obc hindu, common 

quietly logit polint i.observers i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 

outreg2 using "NES2009_women_polint.xls", excel replace keep(3.observers 4.observers) noaster noparen stats(coef se pval)

forval j = 1/200 {
	use "WBW NES2009 Replication.dta", clear
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'

psmatch2 TREATFULL female married educ fathered income urbanicity age sc st obc hindu, common 
quietly logit polint i.observers i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 

outreg2 using "NES2009_women_polint.xls", excel append keep(3.observers 4.observers) noaster noparen stats(coef se pval)

 	}
		
**Manually transpose output in Excel
clear
import excel using "NES2009_women_polint.xls", firstrow
destring spouse spousese spousep fam famse famp, replace
scatter spouse spousep, msize(small)|| scatter fam famp, scheme(lean2) msize(small) msymbol(diamond_hollow) xtitle("P-value") ytitle("Other Adult Family") 


** A20.1: Robustness Check for Answering Political Opinion Questions, 200 Iterations, NES 2009


use "WBW NES2009 Replication.dta", clear

sort st_id pc_id ac_id ps_id res
set seed 12345
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'

psmatch2 TREATFULL female married educ fathered income urbanicity age sc st obc hindu, common 

quietly logit index09 i.observers i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 

outreg2 using "NES2009_women_index09.xls", excel replace keep(3.observers 4.observers) noaster noparen stats(coef se pval)

forval j = 1/200 {
	use "WBW NES2009 Replication.dta", clear
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'

psmatch2 TREATFULL female married educ fathered income urbanicity age sc st obc hindu, common 
quietly logit index09 i.observers i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 

outreg2 using "NES2009_women_index09.xls", excel append keep(3.observers 4.observers) noaster noparen stats(coef se pval)

 	}
		
**Manually transpose output in Excel
clear
import excel using "NES2009_women_index09.xls", firstrow
destring spouse spousese spousep fam famse famp, replace
scatter spouse spousep, msize(small)|| scatter fam famp, scheme(lean2) msize(small) msymbol(diamond_hollow) xtitle("P-value") ytitle("Other Adult Family") 

use "WBW NES2009 Replication.dta", clear

sort st_id pc_id ac_id ps_id res
set seed 12345
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'

psmatch2 TREATFULL female married educ fathered income urbanicity age sc st obc hindu, common 

quietly logit opindex i.observers i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 

outreg2 using "NES2009_women_opindex.xls", excel replace keep(3.observers 4.observers) noaster noparen stats(coef se pval)

forval j = 1/200 {
	use "WBW NES2009 Replication.dta", clear
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'

psmatch2 TREATFULL female married educ fathered income urbanicity age sc st obc hindu, common 
quietly logit opindex i.observers i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 

outreg2 using "NES2009_women_opindex.xls", excel append keep(3.observers 4.observers) noaster noparen stats(coef se pval)

 	}
		
**Manually transpose output in Excel
clear
import excel using "NES2009_women_opindex.xls", firstrow
destring spouse spousese spousep fam famse famp, replace
scatter spouse spousep, msize(small)|| scatter fam famp, scheme(lean2) msize(small) msymbol(diamond_hollow) xtitle("P-value") ytitle("Other Adult Family") 


*** A21.1: Robustness Check for Voting, 200 Iterations, NES 2009
use "WBW NES2009 Replication.dta", clear

sort st_id pc_id ac_id ps_id res
set seed 12345
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'

psmatch2 TREATFULL female married educ fathered income urbanicity age sc st obc hindu, common 

quietly logit vote1 i.observers i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 

outreg2 using "NES2009_women_vote.xls", excel replace keep(3.observers 4.observers) noaster noparen stats(coef se pval)

forval j = 1/200 {
	use "WBW NES2009 Replication.dta", clear
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'

psmatch2 TREATFULL female married educ fathered income urbanicity age sc st obc hindu, common 
quietly logit vote1 i.observers i.st_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 

outreg2 using "NES2009_women_vote.xls", excel append keep(3.observers 4.observers) noaster noparen stats(coef se pval)

 	}
		
**Manually transpose output in Excel
clear
import excel using "NES2009_women_vote.xls", firstrow
destring spouse spousese spousep fam famse famp, replace
scatter spouse spousep, msize(small)|| scatter fam famp, scheme(lean2) msize(small) msymbol(diamond_hollow) xtitle("P-value") ytitle("Other Adult Family") 


*** A22.1: Robustness Check for Political Opinions, 200 Iterations, NES 2014

use "WBW NES2014 Replication.dta", clear


sort state_id pc_id ac_id ps_id resno
set seed 12345
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'


psmatch2 TREATFULL female redu fedu income loca1 age1 sc st obc hindu, common 

quietly logit currentaf i.observers i.state_id [fweight= _weight]if female==0 & _support == 1 & _weight!=., robust 

outreg2 using "NES2014_men_opinion.xls", excel replace keep(3.observers 4.observers) noaster noparen stats(coef se pval)

forval j = 1/200 {
	use "WBW NES2014 Replication.dta", clear
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'

psmatch2 TREATFULL female redu fedu income loca1 age1 sc st obc hindu, common 
quietly logit currentaf i.observers i.state_id [fweight= _weight]if female==0 & _support == 1 & _weight!=., robust 

outreg2 using "NES2014_men_opinion.xls", excel append keep(3.observers 4.observers) noaster noparen stats(coef se pval)

 	}

clear
import excel using "NES2014_men_opinion.xls", firstrow
destring spouse spousese spousep fam famse famp, replace
	
scatter spouse spousep, msize(small)|| scatter fam famp, scheme(lean2) msize(small) msymbol(diamond_hollow) xtitle("P-value") ytitle("Other Adult Family") 



*** A19.2: Robustness Check for Political Interest, 200 Iterations, Original 2019

use "WBW Original2019 Replication.dta", clear


sort sys_tot
set seed 12345
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'

  psmatch2 TREATFULL female married  redu income loca1 age sc st obc hindu, common 

quietly logit polint i.observers i.State_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 

outreg2 using "Orig2019_women_polint.xls", excel replace keep(3.observers 4.observers) noaster noparen stats(coef se pval)

forval j = 1/200 {
	use "WBW Original2019 Replication.dta", clear
tempvar sortorder
gen `sortorder' = runiform()
sort `sortorder'

psmatch2 TREATFULL female married  redu income loca1 age sc st obc hindu, common 
quietly logit polint i.observers i.State_id [fweight= _weight]if female==1 & _support == 1 & _weight!=., robust 

outreg2 using "Orig2019_women_polint.xls", excel append keep(3.observers 4.observers) noaster noparen stats(coef se pval)

 	}

	clear
import excel using "Orig2019_women_polint.xls", firstrow
destring spouse spousese spousep fam famse famp, replace

scatter spouse spousep, scheme(lean1) msize(small) msymbol(circle_hollow) xtitle("P-value") ytitle("Spouse") yline(0.1)
graph save "2019w_spouse.gph", replace
scatter fam famp, scheme(lean1) msize(small) msymbol(diamond_hollow) xtitle("P-value") ytitle("Other Adult Family") 
graph save "2019w_fam.gph", replace

graph combine 2009w_spouse.gph 2009w_fam.gph


*** END ***
*** Please e-mail in62@georgetown.edu and ehaider@wooster.edu if you identify any errors on our part or if you have any questions ***